Skip to content

feat: add distance scores to dense search results - #101

Merged
TanmayArya-1p merged 1 commit into
sdslabs:mainfrom
Arshdeep54:main
Oct 27, 2026
Merged

TanmayArya-1p merged 1 commit into
sdslabs:mainfrom
Arshdeep54:main

Conversation

@Arshdeep54

Copy link
Copy Markdown
Collaborator

Summary

Search results now return a distance score alongside each point ID (lower = closer).

Changes

  • VectorIndex::search returns (PointId, distance) pairs, updated Flat, KD-tree and HNSW
  • HNSW returns true Euclidean distance (sqrt applied), matching Flat and KD-tree
  • HNSW now rejects queries whose similarity differs from the index's
  • Cosine distance returns 1.0 for zero vectors instead of NaN
  • Python client: search / batch_search return (point_id, score) tuples

@Arshdeep54

Copy link
Copy Markdown
Collaborator Author

Pinned toolchain version to 1.98.1

@TanmayArya-1p TanmayArya-1p left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nits for asserting distance in tests. apart from that LGTM

Comment thread crates/api/src/tests.rs
Comment thread crates/index/src/kd_tree/tests.rs Outdated
Comment thread crates/index/src/kd_tree/tests.rs Outdated
@Arshdeep54

Copy link
Copy Markdown
Collaborator Author

@TanmayArya-1p Resolved

@TanmayArya-1p
TanmayArya-1p merged commit 8163b67 into sdslabs:main Oct 27, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants